/**
 * Copyright (c) 2007, Blue Hole Software. All rights reserved.
 * Code licensed under the Apache 2.0 License:
 * http://www.apache.org/licenses/
 */
package org.bhf.i18n;

/**
 * Enumeration for the types of messages.
 */
public enum MessageType
{
    /** ConversionError message, such as a validation error. */
    ERROR,

    /** Information messages, such as confirmation that the last operation succeded. */
    INFO,

    /** Debug message for development. */
    DEBUG;

    /**
     * Create an error message.
     *
     * @param topic If this message is associated with a property on the page, the property
     *  path, such as <code>foo.bar[3].name</code>. If this message is not associated with any
     *  property, the topic may be any other appropriate string. Must not be <code>null</code>.
     * @param summary Must not be <code>null</code>.
     * @param detail If <code>null</code>, defaults to the summary.
     * @param bundle Resource bundle for localizing this message. If <code>null</code>, the message
     *      is considered to have been already localized.
     * @param parameters Message substitution parameters.
     *
     * @return A <code>Message</code>
     */
    public static Message   newError(
        final String            topic,
        final String            summary,
        final String            detail,
        final String            bundle,
        final Object...         parameters
    )
    {
        return new Message( topic, summary, detail, ERROR, bundle, parameters );
    }

    /**
     * Create an informational message.
     *
     * @param topic If this message is associated with a property on the page, the property
     *  path, such as <code>foo.bar[3].name</code>. If this message is not associated with any
     *  property, the topic may be any other appropriate string. Must not be <code>null</code>.
     * @param summary Must not be <code>null</code>.
     * @param detail If <code>null</code>, defaults to the summary.
     * @param bundle Resource bundle for localizing this message. If <code>null</code>, the message
     *      is considered to have been already localized.
     * @param parameters Message substitution parameters.
     *
     * @return A <code>Message</code>
     */
    public static Message   newInfo(
        final String            topic,
        final String            summary,
        final String            detail,
        final String            bundle,
        final Object...         parameters
    )
    {
        return new Message( topic, summary, detail, INFO, bundle, parameters );
    }

    /**
     * Create a debug message. Debug messages are always pre-localized. Thus, they do not have
     * resource bundles.
     *
     * @param topic If this message is associated with a property on the page, the property
     *  path, such as <code>foo.bar[3].name</code>. If this message is not associated with any
     *  property, the topic may be any other appropriate string. Must not be <code>null</code>.
     * @param summary Must not be <code>null</code>.
     * @param detail If <code>null</code>, defaults to the summary.
     * @param parameters Message substitution parameters.
     *
     * @return A <code>Message</code>
     */
    public static Message   newDebug(
        final String            topic,
        final String            summary,
        final String            detail,
        final Object...         parameters
    )
    {
        return new Message( topic, summary, detail, DEBUG, null, parameters );
    }

    /**
     * Create a pre-localized error message.
     *
     * @param topic If this message is associated with a property on the page, the property
     *  path, such as <code>foo.bar[3].name</code>. If this message is not associated with any
     *  property, the topic may be any other appropriate string. Must not be <code>null</code>.
     * @param summary Must not be <code>null</code>.
     * @param detail If <code>null</code>, defaults to the summary.
     * @param parameters Message substitution parameters.
     *
     * @return A <code>Message</code>
     */
    public static Message   newSimpleError(
        final String            topic,
        final String            summary,
        final String            detail,
        final Object...         parameters
    )
    {
        return newError( topic, summary, detail, null, parameters );
    }

    /**
     * Create a pre-localized informational message.
     *
     * @param topic If this message is associated with a property on the page, the property
     *  path, such as <code>foo.bar[3].name</code>. If this message is not associated with any
     *  property, the topic may be any other appropriate string. Must not be <code>null</code>.
     * @param summary Must not be <code>null</code>.
     * @param detail If <code>null</code>, defaults to the summary.
     * @param parameters Message substitution parameters.
     *
     * @return A <code>Message</code>
     */
    public static Message   newSimpleInfo(
        final String            topic,
        final String            summary,
        final String            detail,
        final Object...         parameters
    )
    {
        return newInfo( topic, summary, detail, null, parameters );
    }
}